<template>
  <div class="app-container">
    <el-card class="card-form">
      <div class="expert-title">专家抽取监控</div>
      <el-form :model="queryParams" ref="queryForm" :inline="true">
        <el-form-item label="评审任务" prop="taskName">
          <el-input
            v-model="queryParams.taskName"
            placeholder="请输入"
            clearable
            size="small"
            style="width: 252px"
          />
        </el-form-item>
        <el-form-item label="抽取时间">
          <el-date-picker
            v-model="dateRange"
            size="small"
            style="width: 252px"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="-"
            start-placeholder="请选择..."
            end-placeholder="结束日期"
            @change="changeDate"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="抽取单位" prop="extractUnit">
          <el-select
            v-model="queryParams.extractUnit"
            placeholder="请选择"
            clearable
            size="small"
            style="width: 252px"
          >
            <el-option
              v-for="dict in extractUnitOptions"
              :key="dict.deptId"
              :label="dict.deptName"
              :value="dict.deptId"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" size="small" @click="handleQuery"
            >查询</el-button
          >
          <el-button size="small" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <el-card class="card-table">
      <el-table v-loading="loading" :data="expertList" border>
        <el-table-column label="序号" align="center" type='index' width="65" />
        <el-table-column
          label="评审任务"
          align="center"
          prop="taskName"
          :show-overflow-tooltip="true"
          width="302"
        />
        <el-table-column
          label="抽取时间"
          align="center"
          prop="extractTime"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="抽取数量"
          align="center"
          prop="expertNum"
        />
        <el-table-column
          label="抽取类型"
          align="center"
          prop="extractType"
        >
        <template slot-scope="scope">
          <!-- 1：统一抽取 2：更换专家} -->
          {{scope.row.extractType==1?'统一抽取':'更换专家'}}
        </template>
        </el-table-column>
        <el-table-column
          label="抽取结果"
          align="center"
          prop="extractResult"
        >
        <template slot-scope="scope">
          <!-- 1：发送专家接受 2：重新抽取} -->
          {{scope.row.extractResult==1?'发送专家接受':'重新抽取'}}
        </template>
        </el-table-column>
        <el-table-column label="抽取单位" align="center" prop="extractUnit"/>
        <el-table-column
          label="操作人"
          align="center"
          prop="extractPeople"
        />
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="handleView(scope.row)"
              >查看</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <!-- <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
      /> -->
      <el-pagination
        v-show="total > 0"
        background
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-size="queryParams.pageSize"
        :current-page="queryParams.pageNum"
        :page-sizes="[10, 20, 30, 50, 100]"
      >
      </el-pagination>
    </el-card>
  </div>
</template>
<script>
import {getExpertExtractMonito,getExtractUnit} from "@/api/manage/manage"
export default {
  name: "Expert",
  data() {
    return {
      // 遮罩层
      loading: false,
      // 专家表格数据
      expertList: [
      
      ],
      // 总条数
      total: 1,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 日期范围
      dateRange: [],
      // 抽取单位数据字典
      extractUnitOptions: [],
    };
  },
  created(){
    this.getList()
    this.getQueryItem()
  },
  methods: {
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams= {
        pageNum: 1,
        pageSize: 10,
      }
      this.dateRange=[]
      this.getList()
    },
    /** 查看按钮操作 */
    handleView(row) {
      this.$router.push({
        path: "/tripartite/extractdata/extractdataview",
        query: { reviewTaskId: row.reviewTaskId, extractTime:row.extractTime },
      });
    },
    //获取列表
    getList(){
      getExpertExtractMonito(this.queryParams).then(res =>{
        if(res.code==200){
          this.expertList=res.rows
          this.total = res.total
        }
      })
    },
    //获取抽取单位
    getQueryItem(){
      getExtractUnit().then(res =>{
        if(res.code==200){
          this.extractUnitOptions=res.rows
        }
      })
    },
    //日期处理
    changeDate(val){
      console.log(val)
      if(val){
        this.queryParams.starTime=val[0]+ ' 00:00:00'
        this.queryParams.endTime=val[1]+ ' 23:59:59'
        }     
    },

    /** 分页 */
    handleSizeChange(val) {
      this.queryParams.pageSize=val
      this.getList()
    },
    handleCurrentChange(val) {
      this.queryParams.pageNum=val
      this.getList()
    }
  },
};
</script>
<style scoped lang="scss">
.expert-title {
  font-size: 18px;
  font-family: PingFang SC, PingFang SC-Medium;
  font-weight: 500;
  margin-bottom: 24px;
  color: #000000;
}
.card-table {
  margin-top: 10px;
  .el-pagination {
    text-align: center;
    margin-top: 40px;
  }
}
</style>
<style lang="scss">
.card-form {
  .el-card__body{
    padding-bottom: 0;
  }
  label {
    font-weight: normal !important;
  }
  .el-form--inline .el-form-item {
    margin-right: 60px;
  }
}
.card-table{
  .el-card__body{
    padding: 20px;
  }
}
</style>
